package com.atguigu.realtime.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/11/27 9:23
 */
public class RedisUtil {
    private static JedisPool pool;
    
    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(300);
        config.setMaxIdle(50);
        config.setMinIdle(2);
        config.setTestOnCreate(true);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);
        config.setMaxWaitMillis(10000);
        pool = new JedisPool(config, "hadoop162", 6379);
        
    }
    
    
    public static Jedis getRedisClient(){
        Jedis client = pool.getResource();
        client.select(1);
    
        return client;
    }
}
